menuitem: Remove is_drawable() check
authorBenjamin Otte <otte@redhat.com>
Tue, 14 Sep 2010 11:19:16 +0000 (13:19 +0200)
committerBenjamin Otte <otte@redhat.com>
Sun, 26 Sep 2010 13:11:38 +0000 (15:11 +0200)
gtk/gtkmenuitem.c

index dec347bfc35cc3c79f370ee3bb3a318a7fce531d..5bd093c181f19af8c89eecd20402e18afc8dc7cf 100644 (file)
@@ -1509,7 +1509,7 @@ static gboolean
 gtk_menu_item_draw (GtkWidget *widget,
                     cairo_t   *cr)
 {
-  GtkMenuItem *menu_item;
+  GtkMenuItem *menu_item = GTK_MENU_ITEM (widget);
   GtkStateType state_type;
   GtkShadowType shadow_type, selected_shadow_type;
   GtkStyle *style;
@@ -1518,107 +1518,102 @@ gtk_menu_item_draw (GtkWidget *widget,
   gint x, y, w, h, width, height;
   guint border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
 
-  if (gtk_widget_is_drawable (widget))
-    {
-      menu_item = GTK_MENU_ITEM (widget);
-
-      state_type = gtk_widget_get_state (widget);
-      style = gtk_widget_get_style (widget);
-      window = gtk_widget_get_window (widget);
-      width = gtk_widget_get_allocated_width (widget);
-      height = gtk_widget_get_allocated_height (widget);
+  state_type = gtk_widget_get_state (widget);
+  style = gtk_widget_get_style (widget);
+  window = gtk_widget_get_window (widget);
+  width = gtk_widget_get_allocated_width (widget);
+  height = gtk_widget_get_allocated_height (widget);
 
-      x = border_width;
-      y = border_width;
-      w = width - border_width * 2;
-      h = height - border_width * 2;
+  x = border_width;
+  y = border_width;
+  w = width - border_width * 2;
+  h = height - border_width * 2;
 
-      child = gtk_bin_get_child (GTK_BIN (menu_item));
-      
-      if (child && state_type == GTK_STATE_PRELIGHT)
-       {
-         gtk_widget_style_get (widget,
-                               "selected-shadow-type", &selected_shadow_type,
-                               NULL);
-         gtk_cairo_paint_box (style,
-                         cr,
-                        GTK_STATE_PRELIGHT,
-                        selected_shadow_type,
-                        widget, "menuitem",
-                        x, y, w, h);
-       }
+  child = gtk_bin_get_child (GTK_BIN (menu_item));
   
-      if (menu_item->submenu && menu_item->show_submenu_indicator)
-       {
-         gint arrow_x, arrow_y;
-         gint arrow_size;
-         guint horizontal_padding;
-         GtkTextDirection direction;
-         GtkArrowType arrow_type;
+  if (child && state_type == GTK_STATE_PRELIGHT)
+    {
+      gtk_widget_style_get (widget,
+                            "selected-shadow-type", &selected_shadow_type,
+                            NULL);
+      gtk_cairo_paint_box (style,
+                     cr,
+                     GTK_STATE_PRELIGHT,
+                     selected_shadow_type,
+                     widget, "menuitem",
+                     x, y, w, h);
+    }
 
-         direction = gtk_widget_get_direction (widget);
-      
-         gtk_widget_style_get (widget,
-                               "horizontal-padding", &horizontal_padding,
-                               NULL);
+  if (menu_item->submenu && menu_item->show_submenu_indicator)
+    {
+      gint arrow_x, arrow_y;
+      gint arrow_size;
+      guint horizontal_padding;
+      GtkTextDirection direction;
+      GtkArrowType arrow_type;
 
-         get_arrow_size (widget, child, &arrow_size);
+      direction = gtk_widget_get_direction (widget);
+  
+      gtk_widget_style_get (widget,
+                            "horizontal-padding", &horizontal_padding,
+                            NULL);
 
-         shadow_type = GTK_SHADOW_OUT;
-         if (state_type == GTK_STATE_PRELIGHT)
-           shadow_type = GTK_SHADOW_IN;
+      get_arrow_size (widget, child, &arrow_size);
 
-         if (direction == GTK_TEXT_DIR_LTR)
-           {
-             arrow_x = x + w - horizontal_padding - arrow_size;
-             arrow_type = GTK_ARROW_RIGHT;
-           }
-         else
-           {
-             arrow_x = x + horizontal_padding;
-             arrow_type = GTK_ARROW_LEFT;
-           }
+      shadow_type = GTK_SHADOW_OUT;
+      if (state_type == GTK_STATE_PRELIGHT)
+        shadow_type = GTK_SHADOW_IN;
 
-         arrow_y = y + (h - arrow_size) / 2;
+      if (direction == GTK_TEXT_DIR_LTR)
+        {
+          arrow_x = x + w - horizontal_padding - arrow_size;
+          arrow_type = GTK_ARROW_RIGHT;
+        }
+      else
+        {
+          arrow_x = x + horizontal_padding;
+          arrow_type = GTK_ARROW_LEFT;
+        }
 
-         gtk_cairo_paint_arrow (style, cr,
-                          state_type, shadow_type, 
-                          widget, "menuitem", 
-                          arrow_type, TRUE,
-                          arrow_x, arrow_y,
-                          arrow_size, arrow_size);
-       }
-      else if (!child)
-       {
-          gboolean wide_separators;
-          gint     separator_height;
-         guint    horizontal_padding;
+      arrow_y = y + (h - arrow_size) / 2;
 
-         gtk_widget_style_get (widget,
-                                "wide-separators",    &wide_separators,
-                                "separator-height",   &separator_height,
-                                "horizontal-padding", &horizontal_padding,
-                                NULL);
-
-          if (wide_separators)
-            gtk_cairo_paint_box (style, cr,
-                           GTK_STATE_NORMAL, GTK_SHADOW_ETCHED_OUT,
-                           widget, "hseparator",
-                           horizontal_padding + style->xthickness,
-                           (height - separator_height - style->ythickness) / 2,
-                           width - 2 * (horizontal_padding + style->xthickness),
-                           separator_height);
-          else
-            gtk_cairo_paint_hline (style, cr,
-                             GTK_STATE_NORMAL, widget, "menuitem",
-                             horizontal_padding + style->xthickness,
-                             width - horizontal_padding - style->xthickness - 1,
-                             (height - style->ythickness) / 2);
-       }
+      gtk_cairo_paint_arrow (style, cr,
+                       state_type, shadow_type, 
+                       widget, "menuitem", 
+                       arrow_type, TRUE,
+                       arrow_x, arrow_y,
+                       arrow_size, arrow_size);
+    }
+  else if (!child)
+    {
+      gboolean wide_separators;
+      gint     separator_height;
+      guint    horizontal_padding;
 
-      GTK_WIDGET_CLASS (gtk_menu_item_parent_class)->draw (widget, cr);
+      gtk_widget_style_get (widget,
+                            "wide-separators",    &wide_separators,
+                            "separator-height",   &separator_height,
+                            "horizontal-padding", &horizontal_padding,
+                            NULL);
+
+      if (wide_separators)
+        gtk_cairo_paint_box (style, cr,
+                       GTK_STATE_NORMAL, GTK_SHADOW_ETCHED_OUT,
+                       widget, "hseparator",
+                       horizontal_padding + style->xthickness,
+                       (height - separator_height - style->ythickness) / 2,
+                       width - 2 * (horizontal_padding + style->xthickness),
+                       separator_height);
+      else
+        gtk_cairo_paint_hline (style, cr,
+                         GTK_STATE_NORMAL, widget, "menuitem",
+                         horizontal_padding + style->xthickness,
+                         width - horizontal_padding - style->xthickness - 1,
+                         (height - style->ythickness) / 2);
     }
 
+  GTK_WIDGET_CLASS (gtk_menu_item_parent_class)->draw (widget, cr);
+
   return FALSE;
 }